欢迎光临网上购物商城

当前位置:首页 > 流行男装

ey in obj) { if (obj.hasOwnProperty(key)) size++; } return size; } /*添加收藏*/ function add_favourite(object) { var action=1; if($(object).hasClass('collected')){ action=0; } var source_id=$(object).attr('data-id'); $.ajax({ url: "/add_favourite", data: {source_id:source_id,type:2,action:action}, dataType: 'JSON', type:"POST", sync:false, success: function (res) { if(res.code==200){ layer.msg("操作成功", {icon: 1}); if(action==1){ $(object).addClass('collected') }else{ $(object).removeClass('collected') } }else if(res.code==201){ window.location.href='/login.html'; }else{ layer.msg(res.msg, {icon: 2}); } }, error: function (data) { layer.msg('submit fails', {icon: 5}); } }); } /*添加购物测*/ function addListCart(product_id) { $.ajax({ url: '/add_list_cart', data: {quantity: 1,product_id: product_id}, type: 'POST', dataType: 'json', success: function (data) { if (data.code == 201) { layer.msg(data.msg) setTimeout(function () { window.location.href = '/login' }, 1000) } else if (data.code == 200) { layer.msg(data.msg,{icon:1,time:1000},function () { //添加购物车成功后,刷新右上角的购物车个数即可 window.location.reload(); }); } else { layer.msg(data.msg,{icon:2}) } }, error: function () { console.log("submit fails"); } }); }